package com.ld.zxw.index;

import java.io.IOException;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import com.ld.zxw.config.Config;
import com.ld.zxw.config.IndexFactory;
import com.ld.zxw.util.CommonUtil;
public class UpdateIndex implements IndexFactory{

	private Logger log = Logger.getLogger(UpdateIndex.class);
	
	@Override
	public boolean updateIndexs(Config config, List<Document> list,Term term) {
		try {
			IndexWriter indexWriter = config.getIndexWriter();
			indexWriter.updateDocuments(term, list);
			CommonUtil.refresh(config, indexWriter);
			return true;
		} catch (IOException e) {
			log.error("updateIndexs-error", e);
			return false;
		}
	}
}
